package com.ag.lwc.action;

import java.util.LinkedList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbLogType;
import com.ag.common.BaseAction;
import com.ag.lwc.service.TbLogTypeService;
@Controller("TbLogTypeAction")
public class TbLogTypeAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	@Resource(name="TbLogTypeService")
	private TbLogTypeService service;
	private List<TbLogType> result = new LinkedList<TbLogType>();
	private String ltId;
	private String ltName;
	private String ltColor;
	private String message;
	public String find()
	{
		result = service.findAll();
		System.out.println("***********************数目："+result.size()+"*****************************");
		for(TbLogType l:result)
		{
			System.out.println(l.getLtName());
		}
		message = "find_success";
		return "find_success";
	}
	public String modify()
	{
		TbLogType logType = new TbLogType();
		logType.setLtId(ltId);
		logType.setLtName(ltName);
		logType.setLtColor(ltColor);
		try
		{
			service.update(logType);
			message="change_success";
			
		}
		catch(Exception e)
		{
			message="修改失败";
			
		}
		return "change_success";
	}
	public String save()
	{
		TbLogType logType = new TbLogType();
		logType.setLtId(ltId);
		logType.setLtName(ltName);
		logType.setLtColor(ltColor);
		try
		{
			service.save(logType);
			message="save_success";
			
		}
		catch(Exception e)
		{
			message="保存失败";
			
		}
		return "save_success";
	}
	public String delete()
	{
		try
		{
			service.delete(ltId);
			message = "delete_success";
			
		}
		catch(Exception e)
		{
			message="删除失败";
			
		}
		return "delete_success";
	}
	public String execute()
	{
		result = service.findAll();
		return "success";
	}
	public TbLogTypeService getService() {
		return service;
	}
	public void setService(TbLogTypeService service) {
		this.service = service;
	}
	public List<TbLogType> getResult() {
		return result;
	}
	public void setResult(List<TbLogType> result) {
		this.result = result;
	}
	public String getLtId() {
		return ltId;
	}
	public void setLtId(String ltId) {
		this.ltId = ltId;
	}
	public String getLtName() {
		return ltName;
	}
	public void setLtName(String ltName) {
		this.ltName = ltName;
	}
	public String getLtColor() {
		return ltColor;
	}
	public void setLtColor(String ltColor) {
		this.ltColor = ltColor;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

}
